package com.wchen.dubbo.demo.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.wchen.dubbo.IDubboProvider;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import wchen.dubbo.service.IDubboDemoService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * ${DESCRIPTION}.
 * @author
 * User: wwchen
 * DateTime: 2017/11/26 10:56
 */

/**
 * @Component与@Reference为dubbo配置
 */
@Controller
@Component
@RequestMapping(value = "/customerTest")
public class CustomerAction {

    @Reference
    IDubboProvider dubboProvider;

    @Reference
    IDubboDemoService dubboDemoService;

    @RequestMapping(value = "/test.do")
    @ResponseBody
    public String test(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("application/json;charset=UTF-8");
        String str1 = "消费者";
        String str2 = (dubboProvider.sayHello(" qwe "));
        System.out.println(str1 +":"+ str2);
        return str1 +":"+ str2;
    }

    @RequestMapping(value = "/test1.do")
    @ResponseBody
    public String test1(HttpServletRequest request, HttpServletResponse response){

        return "";
    }
}
